package com.example.helloworld;

public class InstanceCounter {
    private static int counter;

    final int value = 10;
    // 下面是声明常量的实例
    public static final int BOXWIDTH = 6;
    static final String TITLE = "Manager";

    protected static int getCounter(){
        return counter;
    }

    protected static void addCounter(){
        counter++;
    }

    public InstanceCounter() {
        InstanceCounter.addCounter();
    }

//    public void changeValue(){
//        value = 12;
//    }

    public static void main(String[] args) {
        System.out.println("Starting with " +  InstanceCounter.getCounter() + " instances");

        for(int i = 0; i < 500; i++){
            new InstanceCounter();
        }

        System.out.println("Starting with " +  InstanceCounter.getCounter() + " instances");

    }
}
